/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * DColumnas.java
 *
 * Created on 10/02/2010, 09:06:21 AM
 */
package ig.metrica.ui.editor.da;

import ig.ejb.metrica.da.session.editor.dto.ColumnaDTO;
import ig.ejb.metrica.da.session.editor.dto.ColumnaOriegenDatoDTO;
import ig.ejb.metrica.da.session.editor.dto.TablaDTO;
import ig.formato.util.MyTableModel;
import ig.metrica.origenesdedatos.OrigenesdatosDTO;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseWheelEvent;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;
import javax.swing.DefaultCellEditor;
import javax.swing.JComboBox;
import javax.swing.JOptionPane;
import javax.swing.table.TableColumn;

/**
 *
 * @author jsanchez
 */
public class DColumnas extends javax.swing.JDialog {

    private MEditorMetricaDA modelo = null;
    private TablaDTO dTO = null;
    private List<ColumnaDTO> columnaDTOs = null;
    private List<Map> list = new ArrayList<Map>();
    private JComboBox coDatos = new JComboBox();
    private int rowSelect = -1;
    //private JComboBox coDatosLabel=new JComboBox();
    //private JComboBox coDatosValue=new JComboBox();

    /** Creates new form DColumnas */
    public DColumnas(java.awt.Frame parent, TablaDTO dTO, MEditorMetricaDA modelo) throws Exception {
        super(parent, true);
        initComponents();
        this.modelo = modelo;
        this.dTO = dTO;
        setSize(720, 350);
        tAlias.setText(dTO.getDescripcion());
        java.awt.Dimension dimensionScreen = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        java.awt.Rectangle dimensionPantalla = getBounds();
        setLocation((dimensionScreen.width - dimensionPantalla.width) / 2, (dimensionScreen.height - dimensionPantalla.height) / 2);
        cargarTabla();

        tColumnas.getColumnModel().getColumn(0).setPreferredWidth(30);
        tColumnas.getColumnModel().getColumn(0).setMaxWidth(30);
        tColumnas.getColumnModel().getColumn(0).setMinWidth(30);

        /*tColumnas.getColumnModel().getColumn(2).setPreferredWidth(30);
        tColumnas.getColumnModel().getColumn(2).setMaxWidth(30);
        tColumnas.getColumnModel().getColumn(2).setMinWidth(30);*/

        tColumnas.getTableHeader().setReorderingAllowed(false);

        jLabel1.setText(jLabel1.getText() + " [" + dTO.getNombre() + "]");

        coDatos.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                actualizarListas(e);
                setSelectRow(rowSelect);
            }
        });

        coDatos.addMouseListener(new java.awt.event.MouseAdapter() {

            @Override
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                setSelectRow(tColumnas.getSelectedRow());
            }

            @Override
            public void mousePressed(MouseEvent e) {
                setSelectRow(tColumnas.getSelectedRow());
            }

            @Override
            public void mouseReleased(MouseEvent e) {
                setSelectRow(tColumnas.getSelectedRow());
            }

            @Override
            public void mouseDragged(MouseEvent e) {
                setSelectRow(tColumnas.getSelectedRow());
            }

            @Override
            public void mouseEntered(MouseEvent e) {
                setSelectRow(tColumnas.getSelectedRow());
            }

            @Override
            public void mouseExited(MouseEvent e) {
                setSelectRow(tColumnas.getSelectedRow());
            }

            @Override
            public void mouseMoved(MouseEvent e) {
                setSelectRow(tColumnas.getSelectedRow());
            }

            @Override
            public void mouseWheelMoved(MouseWheelEvent e) {
                setSelectRow(tColumnas.getSelectedRow());
            }
        });
        setVisible(true);
    }

    private void actualizarDTO() {
        if (rowSelect > -1) {
            ColumnaDTO columnaDTO = (ColumnaDTO) tColumnas.getValueAt(rowSelect, 1);
            if (tColumnas.getValueAt(rowSelect, 2) instanceof OrigenesdatosDTO) {
                OrigenesdatosDTO origenesdatosDTO = (OrigenesdatosDTO) tColumnas.getValueAt(rowSelect, 2);
                ColumnaOriegenDatoDTO coddto = new ColumnaOriegenDatoDTO();
                coddto.setId_Columna(columnaDTO.getId());
                coddto.setId_ODatos(origenesdatosDTO.getConsecutivo());
                if (lLabel.getSelectedValue() != null && lValor.getSelectedValue() != null){
                    coddto.setColumna_Label(lLabel.getSelectedValue().toString());
                /*}
                if (lValor.getSelectedValue() != null) {*/
                    coddto.setColumna_Valor(lValor.getSelectedValue().toString());
                    columnaDTO.setColumnaOriegenDatoDTO(coddto);
                }                
            }
        }
    }

    private synchronized void setSelectRow(int selectedRow) {
        if (selectedRow > -1 /*&& tColumnas.getSelectedRow()!=selectedRow*/) {
            rowSelect = selectedRow;
            tColumnas.setRowSelectionInterval(rowSelect, rowSelect);
            //actualizarDTO();
        }
    }

    public List<Map> getList() {
        return list;
    }

    private void cargarTabla() throws Exception {
        columnaDTOs = modelo.getColumnTables(dTO.getNombre());
        Object[][] data = new Object[columnaDTOs.size() - 2][3];
        int row = 0;
        for (ColumnaDTO columnaDTO : columnaDTOs) {
            if (!columnaDTO.getNombre().equalsIgnoreCase("ID") && !columnaDTO.getNombre().equalsIgnoreCase("MANUAL")) {
                data[row][0] = columnaDTO.getSeleccion().equals(1);
                data[row][1] = columnaDTO;
                data[row++][2] = columnaDTO.getColumnaOriegenDatoDTO() != null ? modelo.getOriegenDeDato(columnaDTO.getColumnaOriegenDatoDTO().getId_ODatos()) : "<Ninguna>";
            }
        }
        //tColumnas.setModel(new MyTableModel(data, new String[]{"Nombre", "Sel.", "Lista", "Origen de Datos", "Label", "Valor"}, new boolean[]{false, true, true, true, true, true}));
        tColumnas.setModel(new MyTableModel(data, new String[]{"Sel.", "Nombre", "Lista"}, new boolean[]{true, false, true}));
        coDatos.addItem("<Ninguna>");
        Collection<OrigenesdatosDTO> COrigenesDatos = modelo.getOrigenesDatos();
        for (OrigenesdatosDTO elem : COrigenesDatos) {
            if (elem.getId() < 1001 && elem.getConsecutivo() < 1001) {
                coDatos.addItem(elem);
            }
        }

        TableColumn grupos = tColumnas.getColumnModel().getColumn(2);
        grupos.setCellEditor(new DefaultCellEditor(coDatos));

    }

    private void actualizarListas(ActionEvent e) {
        //coDatosLabel.removeAllItems();
        //coDatosValue.removeAllItems();
        List<String> list = new ArrayList<String>();
        //list.add("<Ninguna>");
        boolean isTable = e == null && tColumnas.getSelectedRow() > -1 && (tColumnas.getValueAt(tColumnas.getSelectedRow(), 2) instanceof OrigenesdatosDTO);
        boolean isCombo = e != null && coDatos.getSelectedIndex() > -1 && (coDatos.getSelectedItem() instanceof OrigenesdatosDTO);
        String sLabel = "";
        String sValor = "";
        if (e == null) {
            this.rowSelect = tColumnas.getSelectedRow();
        }

        if (this.rowSelect == -1) {
            return;
        }

        if (isTable || isCombo) {
            OrigenesdatosDTO _dTO = null;
            //System.out.println(this.rowSelect);
            if (isTable) {
                _dTO = (OrigenesdatosDTO) tColumnas.getValueAt(tColumnas.getSelectedRow(), 2);
            } else if (isCombo) {
                _dTO = (OrigenesdatosDTO) coDatos.getSelectedItem();
            }

            ColumnaDTO columnaDTO = (ColumnaDTO) tColumnas.getValueAt(this.rowSelect, 1);
            if (columnaDTO.getColumnaOriegenDatoDTO() != null) {
                sLabel = columnaDTO.getColumnaOriegenDatoDTO().getColumna_Label();
                sValor = columnaDTO.getColumnaOriegenDatoDTO().getColumna_Valor();
            }
            StringTokenizer tokenizer = new StringTokenizer(_dTO.getCampos(), ",");
            while (tokenizer.hasMoreElements()) {
                String value = tokenizer.nextToken().trim();
                list.add(value);
            }
        }
        lLabel.setModel(new ModelList(list));
        lValor.setModel(new ModelList(list));
        if (sLabel != null && !sLabel.trim().isEmpty()) {
            lLabel.setSelectedValue(sLabel, true);
        }
        if (sValor != null && !sValor.trim().isEmpty()) {
            lValor.setSelectedValue(sValor, true);
        }

    }

    class ModelList extends javax.swing.AbstractListModel {

        public ModelList(List<String> list) {
            this.list = list;
        }
        List<String> list = new ArrayList<String>();

        public int getSize() {
            return list.size();
        }

        public Object getElementAt(int i) {
            return list.get(i);
        }
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        jPanel1 = new javax.swing.JPanel();
        bCancelar = new javax.swing.JButton();
        bAceptar = new javax.swing.JButton();
        jLabel2 = new javax.swing.JLabel();
        tAlias = new javax.swing.JTextField();
        jScrollPane1 = new javax.swing.JScrollPane();
        tColumnas = new javax.swing.JTable();
        jPanel2 = new javax.swing.JPanel();
        jPanel3 = new javax.swing.JPanel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jPanel4 = new javax.swing.JPanel();
        jScrollPane2 = new javax.swing.JScrollPane();
        lValor = new javax.swing.JList();
        jScrollPane3 = new javax.swing.JScrollPane();
        lLabel = new javax.swing.JList();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

        jLabel1.setFont(new java.awt.Font("Tahoma", 1, 12));
        jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel1.setText(org.openide.util.NbBundle.getMessage(DColumnas.class, "DColumnas.jLabel1.text")); // NOI18N
        jLabel1.setPreferredSize(new java.awt.Dimension(34, 40));
        getContentPane().add(jLabel1, java.awt.BorderLayout.PAGE_START);

        jPanel1.setBackground(new java.awt.Color(255, 255, 255));
        jPanel1.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jPanel1.setPreferredSize(new java.awt.Dimension(396, 48));

        bCancelar.setText(org.openide.util.NbBundle.getMessage(DColumnas.class, "DColumnas.bCancelar.text")); // NOI18N
        bCancelar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bCancelarActionPerformed(evt);
            }
        });
        bCancelar.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                bCancelarKeyReleased(evt);
            }
        });

        bAceptar.setText(org.openide.util.NbBundle.getMessage(DColumnas.class, "DColumnas.bAceptar.text")); // NOI18N
        bAceptar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bAceptarActionPerformed(evt);
            }
        });
        bAceptar.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                bAceptarKeyReleased(evt);
            }
        });

        jLabel2.setText(org.openide.util.NbBundle.getMessage(DColumnas.class, "DColumnas.jLabel2.text")); // NOI18N

        tAlias.setText(org.openide.util.NbBundle.getMessage(DColumnas.class, "DColumnas.tAlias.text")); // NOI18N

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(tAlias, javax.swing.GroupLayout.DEFAULT_SIZE, 394, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(bAceptar)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(bCancelar)
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(bAceptar, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jLabel2)
                        .addComponent(tAlias, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(bCancelar, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );

        getContentPane().add(jPanel1, java.awt.BorderLayout.PAGE_END);

        jScrollPane1.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {
            public void mouseMoved(java.awt.event.MouseEvent evt) {
                jScrollPane1MouseMoved(evt);
            }
        });
        jScrollPane1.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                jScrollPane1KeyReleased(evt);
            }
        });

        tColumnas.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {

            }
        ));
        tColumnas.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        tColumnas.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                tColumnasMouseReleased(evt);
            }
        });
        tColumnas.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {
            public void mouseMoved(java.awt.event.MouseEvent evt) {
                tColumnasMouseMoved(evt);
            }
        });
        tColumnas.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                tColumnasKeyReleased(evt);
            }
        });
        jScrollPane1.setViewportView(tColumnas);

        getContentPane().add(jScrollPane1, java.awt.BorderLayout.CENTER);

        jPanel2.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));
        jPanel2.setPreferredSize(new java.awt.Dimension(250, 335));
        jPanel2.setLayout(new java.awt.BorderLayout());

        jPanel3.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.CENTER, 0, 0));

        jLabel3.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel3.setText(org.openide.util.NbBundle.getMessage(DColumnas.class, "DColumnas.jLabel3.text")); // NOI18N
        jLabel3.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
        jLabel3.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jLabel3.setPreferredSize(new java.awt.Dimension(122, 18));
        jPanel3.add(jLabel3);

        jLabel4.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel4.setText(org.openide.util.NbBundle.getMessage(DColumnas.class, "DColumnas.jLabel4.text")); // NOI18N
        jLabel4.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
        jLabel4.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jLabel4.setPreferredSize(new java.awt.Dimension(122, 18));
        jPanel3.add(jLabel4);

        jPanel2.add(jPanel3, java.awt.BorderLayout.PAGE_START);

        jPanel4.setLayout(new java.awt.BorderLayout());

        jScrollPane2.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(153, 153, 153)));

        lValor.setModel(new javax.swing.AbstractListModel() {
            String[] strings = { "." };
            public int getSize() { return strings.length; }
            public Object getElementAt(int i) { return strings[i]; }
        });
        lValor.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        lValor.setPreferredSize(new java.awt.Dimension(121, 80));
        lValor.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                lValorMouseReleased(evt);
            }
        });
        lValor.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {
            public void mouseMoved(java.awt.event.MouseEvent evt) {
                lValorMouseMoved(evt);
            }
        });
        lValor.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                lValorKeyReleased(evt);
            }
        });
        jScrollPane2.setViewportView(lValor);

        jPanel4.add(jScrollPane2, java.awt.BorderLayout.LINE_END);

        jScrollPane3.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(153, 153, 153)));

        lLabel.setModel(new javax.swing.AbstractListModel() {
            String[] strings = { "." };
            public int getSize() { return strings.length; }
            public Object getElementAt(int i) { return strings[i]; }
        });
        lLabel.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        lLabel.setPreferredSize(new java.awt.Dimension(121, 80));
        lLabel.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                lLabelMouseReleased(evt);
            }
        });
        lLabel.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {
            public void mouseMoved(java.awt.event.MouseEvent evt) {
                lLabelMouseMoved(evt);
            }
        });
        lLabel.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                lLabelKeyReleased(evt);
            }
        });
        jScrollPane3.setViewportView(lLabel);

        jPanel4.add(jScrollPane3, java.awt.BorderLayout.LINE_START);

        jPanel2.add(jPanel4, java.awt.BorderLayout.CENTER);

        getContentPane().add(jPanel2, java.awt.BorderLayout.LINE_END);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void bCancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bCancelarActionPerformed
        list.clear();
        setVisible(false);
    }//GEN-LAST:event_bCancelarActionPerformed

    private void bAceptarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bAceptarActionPerformed
        try {
            for (int i = 0; i < tColumnas.getRowCount(); i++) {
                ColumnaDTO cdto = (ColumnaDTO) tColumnas.getValueAt(i, 1);
                cdto.setSeleccion((Boolean) tColumnas.getValueAt(i, 0) ? 1 : 0);
            }
            dTO.setColumnas(columnaDTOs);
            Collections.sort(columnaDTOs);
            if (tAlias.getText() != null && tAlias.getText().length() > 100) {
                tAlias.setText(tAlias.getText().substring(0, 100));
            }
            dTO.setDescripcion(tAlias.getText());
            modelo.update(dTO);
            Map<String, Object> map = new HashMap<String, Object>();
            map.put("ID", -1);
            for (int i = 0; i < tColumnas.getRowCount(); i++) {
                if ((Boolean) tColumnas.getValueAt(i, 0)) {
                    ColumnaDTO columnaDTO = columnaDTOs.get(i + 1);
                    map.put(columnaDTO.getNombre(), new NULL());
                }
            }
            //map.put("MANUAL", 1);
            list.add(map);
            setVisible(false);
        } catch (Exception e) {
            JOptionPane.showMessageDialog(this, "Error: " + e);
            e.printStackTrace();
        }

    }//GEN-LAST:event_bAceptarActionPerformed

    private void jScrollPane1KeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jScrollPane1KeyReleased
        if (evt.getKeyCode() == 27) {
            list.clear();
            setVisible(false);
        }
    }//GEN-LAST:event_jScrollPane1KeyReleased

    private void bAceptarKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_bAceptarKeyReleased
        if (evt.getKeyCode() == 27) {
            list.clear();
            setVisible(false);
        }
    }//GEN-LAST:event_bAceptarKeyReleased

    private void bCancelarKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_bCancelarKeyReleased
        if (evt.getKeyCode() == 27) {
            list.clear();
            setVisible(false);
        }
    }//GEN-LAST:event_bCancelarKeyReleased

    private void tColumnasKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_tColumnasKeyReleased
        if (evt.getKeyCode() == 27) {
            list.clear();
            setVisible(false);
        } else if (evt.getKeyCode() == 40 || evt.getKeyCode() == 10 || evt.getKeyCode() == 38) {
            actualizarListas(null);
        }
    }//GEN-LAST:event_tColumnasKeyReleased

    private void tColumnasMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tColumnasMouseReleased
        actualizarListas(null);
    }//GEN-LAST:event_tColumnasMouseReleased

    private void tColumnasMouseMoved(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tColumnasMouseMoved
        this.setSelectRow(rowSelect);
    }//GEN-LAST:event_tColumnasMouseMoved

    private void jScrollPane1MouseMoved(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jScrollPane1MouseMoved
        this.setSelectRow(rowSelect);
    }//GEN-LAST:event_jScrollPane1MouseMoved

    private void lLabelMouseMoved(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lLabelMouseMoved
        this.setSelectRow(rowSelect);
    }//GEN-LAST:event_lLabelMouseMoved

    private void lLabelKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_lLabelKeyReleased
        if (evt.getKeyCode() == 35 || evt.getKeyCode() == 40 || evt.getKeyCode() == 10 || evt.getKeyCode() == 38) {
            actualizarDTO();
        } else {
            System.out.println(evt.getKeyCode());
        }
    }//GEN-LAST:event_lLabelKeyReleased

    private void lValorKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_lValorKeyReleased
        if (evt.getKeyCode() == 35 || evt.getKeyCode() == 40 || evt.getKeyCode() == 10 || evt.getKeyCode() == 38) {
            actualizarDTO();
        }
    }//GEN-LAST:event_lValorKeyReleased

    private void lLabelMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lLabelMouseReleased
        actualizarDTO();
    }//GEN-LAST:event_lLabelMouseReleased

    private void lValorMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lValorMouseReleased
        actualizarDTO();
    }//GEN-LAST:event_lValorMouseReleased

    private void lValorMouseMoved(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lValorMouseMoved
        this.setSelectRow(rowSelect);
    }//GEN-LAST:event_lValorMouseMoved

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton bAceptar;
    private javax.swing.JButton bCancelar;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JList lLabel;
    private javax.swing.JList lValor;
    private javax.swing.JTextField tAlias;
    private javax.swing.JTable tColumnas;
    // End of variables declaration//GEN-END:variables
}
